/***
 * * PROJECT
 * *    ATaG
 * * VERSION
 * *    $Revision: 1.1 $
 * * DATE
 * *    $Date: 2006/11/03 23:09:35 $
 * * LOG
 * *    $Log: NodeAttribute.java,v $
 * *    Revision 1.1  2006/11/03 23:09:35  lmottola
 * *    Changed nodeAttributes package.
 * *
 * *    Revision 1.3  2006/10/25 22:50:27  lmottola
 * *    SSD routing debugged,
 * *
 * *    Revision 1.2  2006/10/23 23:57:02  lmottola
 * *    Redefined equals method.
 * *
 * *    Revision 1.1  2006/10/20 00:27:15  lmottola
 * *    Made NodeAttribute abstract.
 * *
 * *    Revision 1.2  2006/10/19 21:21:52  lmottola
 * *    Added CVS preamble.
 * *
 * *
 * *   ATaG (Abstract Task Graph) - Data-driven Macroprogramming for
 * *                                Sensor Networks
 * *
 * *   This program is free software; you can redistribute it and/or
 * *   modify it under the terms of the GNU General Public License
 * *   as published by the Free Software Foundation; either version 2
 * *   of the License, or (at your option) any later version.
 * *
 * *   This program is distributed in the hope that it will be useful,
 * *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * *   GNU General Public License for more details.
 * *
 * *   You should have received a copy of the GNU General Public License
 * *   along with this program; if not, you may find a copy at the FSF web
 * *   site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
 * *   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * *   Boston, MA  02111-1307, USA
 ***/

package atag.runtime.ln.nodeAttributesForGUI;

import java.io.Serializable;

public abstract class NodeAttribute implements Serializable {

	private static final int HASH_BASE = 42;
	protected String key;
	protected Object value;
	
	public String getKey() {
	 return key;
	}
	
	public Object getValue() {
		return value;
	}
	
	public boolean equals (Object obj) {
		if (!(obj instanceof NodeAttribute)) return false;
		NodeAttribute attr = (NodeAttribute) obj;
		return key.equals(attr.key) && value.equals(attr.value);
	}
	
	/**
	 * Redefines the <code>hashCode</code> methods for attributes.
	 */
	public int hashCode() {
		int hash = HASH_BASE;
		if (key != null) {
			hash *= key.length();
		}
		if (value != null){
			hash += value.hashCode();
		}
		return hash;
	}
	
}
